home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / pascal.vim < prev    next >
Encoding:
Text File  |  2001-05-11  |  14.2 KB  |  354 lines

  1. " Vim syntax file
  2. " Language:    Pascal
  3. " Current  Maintainer:  Xavier Crégut <xavier.cregut@enseeiht.fr>
  4. " Previous Maintainer:    Mario Eusebio <bio@dq.fct.unl.pt>
  5. " Version: 2.4
  6. " Last Change:    2001 May 10
  7. " Contributors: Tim Chase <tchase@csc.com>, Stas Grabois <stsi@vtrails.com>
  8.  
  9. " For version 5.x: Clear all syntax items
  10. " For version 6.x: Quit when a syntax file was already loaded
  11. if version < 600
  12.   syntax clear
  13. elseif exists("b:current_syntax")
  14.   finish
  15. endif
  16.  
  17.  
  18. syn case ignore
  19. syn sync lines=250
  20.  
  21. syn keyword pascalBoolean    true false
  22. syn keyword pascalConditional    if else then
  23. syn keyword pascalConstant    nil maxint
  24. syn keyword pascalLabel        case goto label
  25. syn keyword pascalOperator    and div downto in mod not of or packed with
  26. syn keyword pascalRepeat    do for do repeat while to until
  27. syn keyword pascalStatement    procedure function
  28. syn keyword pascalStatement    program begin end const var type
  29. syn keyword pascalStruct    record
  30. syn keyword pascalType        array boolean char integer file pointer real set
  31. syn keyword pascalType        string text
  32.  
  33.  
  34. syn keyword pascalTodo contained    TODO
  35.  
  36.  
  37. " String
  38. if !exists("pascal_one_line_string")
  39.   syn region  pascalString matchgroup=pascalString start=+'+ end=+'+ contains=pascalStringEscape
  40.   if exists("pascal_gpc")
  41.     syn region  pascalString matchgroup=pascalString start=+"+ end=+"+ contains=pascalStringEscapeGPC
  42.   else
  43.     syn region  pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ contains=pascalStringEscape
  44.   endif
  45. else
  46.   "wrong strings
  47.   syn region  pascalStringError matchgroup=pascalStringError start=+'+ end=+'+ end=+$+ contains=pascalStringEscape
  48.   if exists("pascal_gpc")
  49.     syn region  pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ end=+$+ contains=pascalStringEscapeGPC
  50.   else
  51.     syn region  pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ end=+$+ contains=pascalStringEscape
  52.   endif
  53.  
  54.   "right strings
  55.   syn region  pascalString matchgroup=pascalString start=+'+ end=+'+ oneline contains=pascalStringEscape
  56.   " To see the start and end of strings:
  57.   " syn region  pascalString matchgroup=pascalStringError start=+'+ end=+'+ oneline contains=pascalStringEscape
  58.   if exists("pascal_gpc")
  59.     syn region  pascalString matchgroup=pascalString start=+"+ end=+"+ oneline contains=pascalStringEscapeGPC
  60.   else
  61.     syn region  pascalStringError matchgroup=pascalStringError start=+"+ end=+"+ oneline contains=pascalStringEscape
  62.   endif
  63. end
  64. syn match   pascalStringEscape        contained "''"
  65. syn match   pascalStringEscapeGPC    contained '""'
  66.  
  67.  
  68. " syn match   pascalIdentifier        "\<[a-zA-Z_][a-zA-Z0-9_]*\>"
  69.  
  70.  
  71. if exists("pascal_symbol_operator")
  72.   syn match   pascalSymbolOperator      "[+\-/*=]"
  73.   syn match   pascalSymbolOperator      "[<>]=\="
  74.   syn match   pascalSymbolOperator      "<>"
  75.   syn match   pascalSymbolOperator      ":="
  76.   syn match   pascalSymbolOperator      "[()]"
  77.   syn match   pascalSymbolOperator      "\.\."
  78.   syn match   pascalSymbolOperator       "[\^.]"
  79.   syn match   pascalMatrixDelimiter    "[][]"
  80.   "if you prefer you can highlight the range
  81.   "syn match  pascalMatrixDelimiter    "[\d\+\.\.\d\+]"
  82. endif
  83.  
  84. syn match  pascalNumber        "-\=\<\d\+\>"
  85. syn match  pascalFloat        "-\=\<\d\+\.\d\+\>"
  86. syn match  pascalFloat        "-\=\<\d\+\.\d\+[eE]-\=\d\+\>"
  87. syn match  pascalHexNumber    "\$[0-9a-fA-F]\+\>"
  88.  
  89. if exists("pascal_no_tabs")
  90.   syn match pascalShowTab "\t"
  91. endif
  92.  
  93. syn region pascalComment    start="(\*"  end="\*)" contains=pascalTodo
  94. syn region pascalComment    start="{"  end="}" contains=pascalTodo
  95.  
  96.  
  97. if !exists("pascal_no_functions")
  98.   " array functions
  99.   syn keyword pascalFunction    pack unpack
  100.  
  101.   " memory function
  102.   syn keyword pascalFunction    Dispose New
  103.  
  104.   " math functions
  105.   syn keyword pascalFunction    Abs Arctan Cos Exp Ln Sin Sqr Sqrt
  106.  
  107.   " file functions
  108.   syn keyword pascalFunction    Eof Eoln Write Writeln
  109.   syn keyword pascalPredefined    Input Output
  110.  
  111.   if exists("pascal_traditional")
  112.     " These functions do not seem to be defined in Turbo Pascal
  113.     syn keyword pascalFunction    Get Page Put
  114.   endif
  115.  
  116.   " ordinal functions
  117.   syn keyword pascalFunction    Odd Pred Succ
  118.  
  119.   " transfert functions
  120.   syn keyword pascalFunction    Chr Ord Round Trunc
  121. endif
  122.  
  123.  
  124. if !exists("pascal_traditional")
  125.  
  126.   syn keyword pascalStatement    constructor destructor implementation inherited
  127.   syn keyword pascalStatement    interface unit uses
  128.   syn keyword pascalModifier    absolute assembler external far forward inline
  129.   syn keyword pascalModifier    interrupt near virtual
  130.   syn keyword pascalAcces    private public
  131.   syn keyword pascalStruct    object
  132.   syn keyword pascalOperator    shl shr xor
  133.  
  134.   syn region pascalPreProc    start="(\*\$"  end="\*)" contains=pascalTodo
  135.   syn region pascalPreProc    start="{\$"  end="}"
  136.  
  137.   syn region  pascalAsm        matchgroup=pascalAsmKey start="\<asm\>" end="\<end\>" contains=pascalComment,pascalPreProc
  138.  
  139.   syn keyword pascalType    ShortInt LongInt Byte Word
  140.   syn keyword pascalType    ByteBool WordBool LongBool
  141.   syn keyword pascalType    Cardinal LongWord
  142.   syn keyword pascalType    Single Double Extended Comp
  143.   syn keyword pascalType    PChar
  144.  
  145.  
  146.   if !exists ("pascal_fpc")
  147.     syn keyword pascalPredefined    Result
  148.   endif
  149.  
  150.   if exists("pascal_fpc")
  151.     syn keyword pascalStatement    fail otherwise
  152.     syn keyword pascalDirective    popstack
  153.     syn keyword pascalPredefined self
  154.     syn keyword pascalType    ShortString AnsiString WideString
  155.   endif
  156.  
  157.   if exists("pascal_gpc")
  158.     syn keyword pascalType    SmallInt
  159.     syn keyword pascalType    AnsiChar
  160.     syn keyword pascalType    PAnsiChar
  161.   endif
  162.  
  163.   if exists("pascal_delphi")
  164.     syn region pascalComment    start="//"  end="$" contains=pascalTodo
  165.     syn keyword pascalType    SmallInt Int64
  166.     syn keyword pascalType    Real48 Currency
  167.     syn keyword pascalType    AnsiChar WideChar
  168.     syn keyword pascalType    ShortString AnsiString WideString
  169.     syn keyword pascalType    PAnsiChar PWideChar
  170.     syn match  pascalFloat    "-\=\<\d\+\.\d\+[dD]-\=\d\+\>"
  171.     syn match  pascalStringEscape    contained "#[12][0-9]\=[0-9]\="
  172.     syn keyword pascalStruct    class dispinterface
  173.     syn keyword pascalException    try except raise at on finally
  174.     syn keyword pascalStatement    out
  175.     syn keyword pascalStatement    library package
  176.     syn keyword pascalStatement    initialization finalization uses exports
  177.     syn keyword pascalStatement    property out resourcestring threadvar
  178.     syn keyword pascalModifier    contains
  179.     syn keyword pascalModifier    overridden reintroduce abstract
  180.     syn keyword pascalModifier    override export dynamic name message
  181.     syn keyword pascalModifier    dispid index stored default nodefault readonly
  182.     syn keyword pascalModifier    writeonly implements overload requires resident
  183.     syn keyword pascalAcces    protected published automated
  184.     syn keyword pascalDirective    register pascal cdecl stdcall safecall
  185.     syn keyword pascalOperator    as is
  186.   endif
  187.  
  188.   if exists("pascal_no_functions")
  189.     "syn keyword pascalModifier    read write
  190.     "may confuse with Read and Write functions.  Not easy to handle.
  191.   else
  192.     " control flow functions
  193.     syn keyword pascalFunction    Break Continue Exit Halt RunError
  194.  
  195.     " ordinal functions
  196.     syn keyword pascalFunction    Dec Inc High Low
  197.  
  198.     " math functions
  199.     syn keyword pascalFunction    Frac Int Pi
  200.  
  201.     " string functions
  202.     syn keyword pascalFunction    Concat Copy Delete Insert Length Pos Str Val
  203.  
  204.     " memory function
  205.     syn keyword pascalFunction    FreeMem GetMem MaxAvail MemAvail
  206.  
  207.     " pointer and address functions
  208.     syn keyword pascalFunction    Addr Assigned CSeg DSeg Ofs Ptr Seg SPtr SSeg
  209.  
  210.     " misc functions
  211.     syn keyword pascalFunction    Exclude FillChar Hi Include Lo Move ParamCount
  212.     syn keyword pascalFunction    ParamStr Random Randomize SizeOf Swap TypeOf
  213.     syn keyword pascalFunction    UpCase
  214.  
  215.     " predefined variables
  216.     syn keyword pascalPredefined ErrorAddr ExitCode ExitProc FileMode FreeList
  217.     syn keyword pascalPredefined FreeZero HeapEnd HeapError HeapOrg HeapPtr
  218.     syn keyword pascalPredefined InOutRes OvrCodeList OvrDebugPtr OvrDosHandle
  219.     syn keyword pascalPredefined OvrEmsHandle OvrHeapEnd OvrHeapOrg OvrHeapPtr
  220.     syn keyword pascalPredefined OvrHeapSize OvrLoadList PrefixSeg RandSeed
  221.     syn keyword pascalPredefined SaveInt00 SaveInt02 SaveInt1B SaveInt21
  222.     syn keyword pascalPredefined SaveInt23 SaveInt24 SaveInt34 SaveInt35
  223.     syn keyword pascalPredefined SaveInt36 SaveInt37 SaveInt38 SaveInt39
  224.     syn keyword pascalPredefined SaveInt3A SaveInt3B SaveInt3C SaveInt3D
  225.     syn keyword pascalPredefined SaveInt3E SaveInt3F SaveInt75 SegA000 SegB000
  226.     syn keyword pascalPredefined SegB800 SelectorInc StackLimit Test8087
  227.  
  228.     " file functions
  229.     syn keyword pascalFunction    Append Assign BlockRead BlockWrite ChDir Close
  230.     syn keyword pascalFunction    Erase FilePos FileSize Flush GetDir IOResult
  231.     syn keyword pascalFunction    MkDir Read Readln Rename Reset Rewrite RmDir
  232.     syn keyword pascalFunction    Seek SeekEof SeekEoln SetTextBuf Truncate
  233.  
  234.     " crt unit
  235.     syn keyword pascalFunction    AssignCrt ClrEol ClrScr Delay DelLine GotoXY
  236.     syn keyword pascalFunction    HighVideo InsLine KeyPressed LowVideo NormVideo
  237.     syn keyword pascalFunction    NoSound ReadKey Sound TextBackground TextColor
  238.     syn keyword pascalFunction    TextMode WhereX WhereY Window
  239.     syn keyword pascalPredefined CheckBreak CheckEOF CheckSnow DirectVideo
  240.     syn keyword pascalPredefined LastMode TextAttr WindMin WindMax
  241.     syn keyword pascalFunction BigCursor CursorOff CursorOn
  242.     syn keyword pascalConstant Black Blue Green Cyan Red Magenta Brown
  243.     syn keyword pascalConstant LightGray DarkGray LightBlue LightGreen
  244.     syn keyword pascalConstant LightCyan LightRed LightMagenta Yellow White
  245.     syn keyword pascalConstant Blink ScreenWidth ScreenHeight bw40
  246.     syn keyword pascalConstant co40 bw80 co80 mono
  247.     syn keyword pascalPredefined TextChar
  248.  
  249.     " DOS unit
  250.     syn keyword pascalFunction    AddDisk DiskFree DiskSize DosExitCode DosVersion
  251.     syn keyword pascalFunction    EnvCount EnvStr Exec Expand FindClose FindFirst
  252.     syn keyword pascalFunction    FindNext FSearch FSplit GetCBreak GetDate
  253.     syn keyword pascalFunction    GetEnv GetFAttr GetFTime GetIntVec GetTime
  254.     syn keyword pascalFunction    GetVerify Intr Keep MSDos PackTime SetCBreak
  255.     syn keyword pascalFunction    SetDate SetFAttr SetFTime SetIntVec SetTime
  256.     syn keyword pascalFunction    SetVerify SwapVectors UnPackTime
  257.     syn keyword pascalConstant    FCarry FParity FAuxiliary FZero FSign FOverflow
  258.     syn keyword pascalConstant    Hidden Sysfile VolumeId Directory Archive
  259.     syn keyword pascalConstant    AnyFile fmClosed fmInput fmOutput fmInout
  260.     syn keyword pascalConstant    TextRecNameLength TextRecBufSize
  261.     syn keyword pascalType    ComStr PathStr DirStr NameStr ExtStr SearchRec
  262.     syn keyword pascalType    FileRec TextBuf TextRec Registers DateTime
  263.     syn keyword pascalPredefined DosError
  264.  
  265.     "Graph Unit
  266.     syn keyword pascalFunction    Arc Bar Bar3D Circle ClearDevice ClearViewPort
  267.     syn keyword pascalFunction    CloseGraph DetectGraph DrawPoly Ellipse
  268.     syn keyword pascalFunction    FillEllipse FillPoly FloodFill GetArcCoords
  269.     syn keyword pascalFunction    GetAspectRatio GetBkColor GetColor
  270.     syn keyword pascalFunction    GetDefaultPalette GetDriverName GetFillPattern
  271.     syn keyword pascalFunction    GetFillSettings GetGraphMode GetImage
  272.     syn keyword pascalFunction    GetLineSettings GetMaxColor GetMaxMode GetMaxX
  273.     syn keyword pascalFunction    GetMaxY GetModeName GetModeRange GetPalette
  274.     syn keyword pascalFunction    GetPaletteSize GetPixel GetTextSettings
  275.     syn keyword pascalFunction    GetViewSettings GetX GetY GraphDefaults
  276.     syn keyword pascalFunction    GraphErrorMsg GraphResult ImageSize InitGraph
  277.     syn keyword pascalFunction    InstallUserDriver InstallUserFont Line LineRel
  278.     syn keyword pascalFunction    LineTo MoveRel MoveTo OutText OutTextXY
  279.     syn keyword pascalFunction    PieSlice PutImage PutPixel Rectangle
  280.     syn keyword pascalFunction    RegisterBGIDriver RegisterBGIFont
  281.     syn keyword pascalFunction    RestoreCRTMode Sector SetActivePage
  282.     syn keyword pascalFunction    SetAllPallette SetAspectRatio SetBkColor
  283.     syn keyword pascalFunction    SetColor SetFillPattern SetFillStyle
  284.     syn keyword pascalFunction    SetGraphBufSize SetGraphMode SetLineStyle
  285.     syn keyword pascalFunction    SetPalette SetRGBPalette SetTextJustify
  286.     syn keyword pascalFunction    SetTextStyle SetUserCharSize SetViewPort
  287.     syn keyword pascalFunction    SetVisualPage SetWriteMode TextHeight TextWidth
  288.     syn keyword pascalType    ArcCoordsType FillPatternType FillSettingsType
  289.     syn keyword pascalType    LineSettingsType PaletteType PointType
  290.     syn keyword pascalType    TextSettingsType ViewPortType
  291.  
  292.     " string functions
  293.     syn keyword pascalFunction    StrAlloc StrBufSize StrCat StrComp StrCopy
  294.     syn keyword pascalFunction    StrDispose StrECopy StrEnd StrFmt StrIComp
  295.     syn keyword pascalFunction    StrLCat StrLComp StrLCopy StrLen StrLFmt
  296.     syn keyword pascalFunction    StrLIComp StrLower StrMove StrNew StrPas
  297.     syn keyword pascalFunction    StrPCopy StrPLCopy StrPos StrRScan StrScan
  298.     syn keyword pascalFunction    StrUpper
  299.   endif
  300.  
  301. endif
  302.  
  303. " Define the default highlighting.
  304. " For version 5.7 and earlier: only when not done already
  305. " For version 5.8 and later: only when an item doesn't have highlighting yet
  306. if version >= 508 || !exists("did_pascal_syn_inits")
  307.   if version < 508
  308.     let did_pascal_syn_inits = 1
  309.     command -nargs=+ HiLink hi link <args>
  310.   else
  311.     command -nargs=+ HiLink hi def link <args>
  312.   endif
  313.  
  314.   HiLink pascalAcces        pascalStatement
  315.   HiLink pascalBoolean        Boolean
  316.   HiLink pascalComment        Comment
  317.   HiLink pascalConditional    Conditional
  318.   HiLink pascalConstant        Constant
  319.   HiLink pascalDelimiter    Identifier
  320.   HiLink pascalDirective    pascalStatement
  321.   HiLink pascalException    Exception
  322.   HiLink pascalFloat        Float
  323.   HiLink pascalFunction        Function
  324.   HiLink pascalLabel        Label
  325.   HiLink pascalMatrixDelimiter    Identifier
  326.   HiLink pascalModifier        Type
  327.   HiLink pascalNumber        Number
  328.   HiLink pascalOperator        Operator
  329.   HiLink pascalPredefined    pascalStatement
  330.   HiLink pascalPreProc        PreProc
  331.   HiLink pascalRepeat        Repeat
  332.   HiLink pascalStatement    Statement
  333.   HiLink pascalString        String
  334.   HiLink pascalStringEscape    Special
  335.   HiLink pascalStringEscapeGPC    Special
  336.   HiLink pascalStringError    Error
  337.   HiLink pascalStruct        pascalStatement
  338.   HiLink pascalSymbolOperator    pascalOperator
  339.   HiLink pascalTodo        Todo
  340.   HiLink pascalType        Type
  341.   HiLink pascalUnclassified    pascalStatement
  342.   "  HiLink pascalAsm        Assembler
  343.   HiLink pascalError        Error
  344.   HiLink pascalAsmKey        pascalStatement
  345.   HiLink pascalShowTab        Error
  346.  
  347.   delcommand HiLink
  348. endif
  349.  
  350.  
  351. let b:current_syntax = "pascal"
  352.  
  353. " vim: ts=8 sw=2
  354.